/*
 * @Author: wangwei wwdqq7@qq.com
 * @Date: 2025-04-01 15:00:00
 * @LastEditors: wangwei wwdqq7@qq.com
 * @LastEditTime: 2025-04-01 15:00:00
 * @FilePath: /FullStack/pro/typeorm-mysql/src/auth/decorators/permissions.decorator.ts
 * @Description: 权限装饰器，用于标记需要特定权限的API端点
 */
import { SetMetadata } from '@nestjs/common';
import { applyDecorators } from '@nestjs/common';
import { ApiSecurity } from '@nestjs/swagger';

export const PERMISSIONS_KEY = 'permissions';

/**
 * 权限装饰器，用于标记需要特定权限的API端点
 * @param permissions 所需权限列表
 * @returns 装饰器
 */
export const RequirePermissions = (...permissions: string[]) => {
  return applyDecorators(
    SetMetadata(PERMISSIONS_KEY, permissions),
    ApiSecurity('bearer', ['JWT']), // 在Swagger文档中标记需要JWT认证
  );
};
